﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CrossLayerCommunication.FluentValidation
{
    public interface IFluentValidationResult
    {
        IMessage ValidationMessage { get; }
        bool ValidationWasSuccessful { get; }
    }

    public interface IFluentValidation<out T> : IFluentValidationResult
    {
        T ValidatedValue { get; }
        bool WasLastValidationConditionMet { get; }
    }

    internal class FluentValidation<T> : IFluentValidation<T>
    {
        protected IMessage message;
        public IMessage ValidationMessage { get { return message; } }

        protected bool isValid;
        public bool ValidationWasSuccessful { get { return isValid; } }

        protected bool wasLastValidationConditionMet;
        public bool WasLastValidationConditionMet { get { return wasLastValidationConditionMet; } }

        protected T value;
        public T ValidatedValue { get { return value; } }

        internal FluentValidation(T valueToValidate, IMessage message, bool isValid = true, bool wasLastValidationConditionMet = true)
        {            
            this.value = valueToValidate;
            this.message = message;
            this.isValid = isValid;
            this.wasLastValidationConditionMet = wasLastValidationConditionMet;
        }
    }
}
